/**
 * @param {number[][]} questions
 * @return {number}
 */
 var mostPoints = function(questions) {
  const n = questions.length
  const memo = {}
  const dfs = (i) => {
    if(i >= n) return 0
    if(memo[i]) return memo[i]
    let [p, diff] = questions[i]
    memo[i] = Math.max(p+dfs(i+diff+1), dfs(i+1))
    return memo[i]
  }
  return dfs(0)
};
